package com.leo;

import javafx.application.Application;
import javafx.geometry.Point3D;
import javafx.scene.*;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Box;
import javafx.scene.shape.Cylinder;
import javafx.scene.shape.Sphere;
import javafx.stage.Stage;

/**
 * @ClassName PointLightDemo
 * @Description 点光源
 * @Author wangss
 * @date 2020.07.05 18:23
 * @Version 1.0
 */
public class PointLightDemo extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        AnchorPane an = new AnchorPane();

        HBox hBox = new HBox(100);

        Box box = new Box(150, 150, 150);

        Cylinder cylinder = new Cylinder(50, 200, 64);

        Point3D point3D = new Point3D(1, 0, 0);
        cylinder.setRotationAxis(point3D);
        cylinder.setRotate(60);

        Sphere sphere = new Sphere(100, 64);

        hBox.getChildren().addAll(box, cylinder, sphere);

        PointLight pointLight = new PointLight();
        pointLight.setColor(Color.WHITE);

        pointLight.setTranslateX(600);
        pointLight.setTranslateY(600);

        an.setStyle("-fx-background-color: #FFFFFF00");
        an.getChildren().addAll(hBox, pointLight);
        an.setDepthTest(DepthTest.ENABLE);
        AnchorPane.setTopAnchor(hBox, 100d);
        AnchorPane.setLeftAnchor(hBox, 300d);

        Scene scene = new Scene(an, 1200, 800, true, SceneAntialiasing.BALANCED);
        scene.setCamera(new PerspectiveCamera());

        primaryStage.setScene(scene);
        primaryStage.setTitle("3D介绍");
        primaryStage.setWidth(1200);
        primaryStage.setHeight(800);
        primaryStage.show();
    }
}
